import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

class ProteinTranslator {

    private final static Map<String, Integer> PolypeptideIndexMap = new HashMap<>();

    private final static Map<String, String> PolypeptideMap = new HashMap<>();

    static {
        PolypeptideMap.put("AUG", "Methionine");
        PolypeptideIndexMap.put("Methionine", 0);

        PolypeptideMap.put("UUU", "Phenylalanine");
        PolypeptideMap.put("UUC", "Phenylalanine");
        PolypeptideIndexMap.put("Phenylalanine", 1);

        PolypeptideMap.put("UUA", "Leucine");
        PolypeptideMap.put("UUG", "Leucine");
        PolypeptideIndexMap.put("Leucine", 2);

        PolypeptideMap.put("UCU", "Serine");
        PolypeptideMap.put("UCC", "Serine");
        PolypeptideMap.put("UCA", "Serine");
        PolypeptideMap.put("UCG", "Serine");
        PolypeptideIndexMap.put("Serine", 3);

        PolypeptideMap.put("UGG", "Tryptophan");
        PolypeptideIndexMap.put("Tryptophan", 4);

        PolypeptideMap.put("UGU", "Cysteine");
        PolypeptideMap.put("UGC", "Cysteine");
        PolypeptideIndexMap.put("Cysteine", 5);

        PolypeptideMap.put("UAU", "Tyrosine");
        PolypeptideMap.put("UAC", "Tyrosine");
        PolypeptideIndexMap.put("Tyrosine", 6);

        PolypeptideMap.put("UAA", "STOP");
        PolypeptideMap.put("UAG", "STOP");
        PolypeptideMap.put("UGA", "STOP");
    }

    List<String> translate(final String rnaSequence) {
        final int length = rnaSequence.length() / 3;

        String[] polypeptideIndex = new String[7];
        for (int i = 0; i < length; i++) {
            final String t = ProteinTranslator.PolypeptideMap.get(rnaSequence.substring(i * 3, i * 3 + 3));
            if (t.equals("STOP")) break;

            polypeptideIndex[ProteinTranslator.PolypeptideIndexMap.get(t)] = t;
        }


        return Arrays.stream(polypeptideIndex)
                .filter(Objects::nonNull)
                .collect(Collectors.toList());
    }
}